package com.gexiaobao.pigeon.ui.dialog

import android.annotation.SuppressLint
import android.content.Context
import android.view.LayoutInflater
import android.view.View
import androidx.appcompat.widget.AppCompatButton
import androidx.appcompat.widget.AppCompatEditText
import androidx.appcompat.widget.AppCompatImageView
import androidx.appcompat.widget.AppCompatTextView
import com.gexiaobao.pigeon.R

/**
 * @author:hxw
 * @date  :2022/12/8
 * @desc  :
 */
class RxDialogPrintCode(context: Context?) : RxDialog(context!!) {

    private lateinit var sureView: AppCompatButton
    private lateinit var ivClose: AppCompatImageView
    private lateinit var etPrintCode: AppCompatEditText

    init {
        initView()
    }

    @SuppressLint("MissingInflatedId")
    private fun initView() {
        val dialogView = LayoutInflater.from(context).inflate(R.layout.dialog_print_code, null)
        sureView = dialogView.findViewById(R.id.tvDialogSure)
        ivClose = dialogView.findViewById(R.id.ivDefaultClose)
        etPrintCode = dialogView.findViewById(R.id.etPrintCode)

        ivClose.setOnClickListener {
            dismiss()
        }
        setContentView(dialogView)
    }

    fun getPrintCode(): String {
        return etPrintCode.text.toString().trim()
    }

    fun setSureListener(listener: View.OnClickListener?) {
        sureView.setOnClickListener(listener)
    }
}